{% for host in (groups['all']|unique) %}
{% if hostvars[host] is defined -%}
---
apiVersion: cluster.buildrun.io/v1
kind: Machine
metadata:
  name: "{{ hostvars[host].inventory_hostname }}"
spec:
  # Add fields here
  roles:
{% if host in groups['kube-master'] %}
  - master
{% endif %}
{% if host in groups['kube-worker'] %}
  - worker
{% endif %}
{% if host in groups['etcd'] %}
  - etcd
{% endif %}
  sshConfig:
     host: "{{ hostvars[host].inventory_hostname }}"
     username: {{ hostvars[host].ansible_user }}
     port: {{ hostvars[host].ansible_port }}
     authorization:
       password: {{ hostvars[host].ansible_ssh_pass }}

{% endif %}
{% endfor %}